Variable Text on a Button

Description

The text on a button can be derived from a variable. Where width is the width of the button in characters, height is the height of the button in lines, event_name is the name of the event ( a_dlg_button will be set to this value when the button is clicked) and ?condition is an optional logical condition that determines whether the button is enabled or disabled.

The following script displays a dialog with a button labeled "Save File". After the button is clicked, the button changes to "Open File".

button_text = "Save File"
ui_dlg_box("Button Text from a Variable",<<%dlg%
<15,2=button_text!button1> <10,2Close>
%dlg%,<<%code%
if a_dlg_button = "button1" then
    a_dlg_button = ""
    if button_text = "Save File" then
        button_text = "Open File"
    else
        button_text = "Save File"
    end if
end if
%code%)

This script produces the following dialog and displays variable text on the button:

images/XD_Variable_Button_Text_2.gif

After you click on the Save File button, the dialog looks like this:

images/XD_Variable_Button_Text_1.gif

Limitations

Desktop applications only

See Also